/*
 * OptionMenuPane.java
 *
 * Copyright 2011 Universidad Francisco de Paula Santander (UFPS).
 * Todos los Derechos Reservados.
 * Creado el 24/04/2011, 12:58:35 AM
 */
package com.ufps.cuatro.modelo.representacion;

import com.ufps.cuatro.util.base.ObjectBase;

/**
 * <i><b>OptionMenuPane:</b></i><p>Representa una Opción de Menu.</p> * 
 * 
 * @author Carlos A. Torres C. - Dolly E. Guerrero. <https://code.google.com/p/tesis4dor/> 
 * @see ObjectBase
 */
public class OptionMenuPane extends ObjectBase{
    private static final long serialVersionUID = -2685294249609894018L;
    
    private String strLabel;
    private String strCommand;
    public static int idOption = 0;
    

    public OptionMenuPane(String strLabel) {
        super(idOption++);
        this.strLabel = strLabel;                
        strCommand = strLabel.replaceFirst(" ", "");
    }   

    public String getStrCommand() {
        return strCommand;
    }

    public void setStrCommand(String strCommand) {
        this.strCommand = strCommand;
    }

    public String getStrLabel() {
        return strLabel;
    }

    public void setStrLabel(String strLabel) {
        this.strLabel = strLabel;
        strCommand = strLabel.replaceFirst(" ", "");
    }

    @Override
    public String toString() {
        return "Option:" + strLabel + ", Command=" + strCommand;
    }

    @Override    
    public int compareTo(Object o) {        
        OptionMenuPane obj = (OptionMenuPane) o;
        if(this.id > obj.id) {
            return 1;
        }
        else if(this.id < obj.id) {
            return -1;
        }
        else {
            return 0;
        }
    }

    @Override
    public boolean equals(Object obj) {
        if(obj instanceof OptionMenuPane){
            OptionMenuPane objOption = (OptionMenuPane) obj;
            return strLabel.equals(objOption.getStrLabel());
        }
        return super.equals(obj);
    }

    @Override
    public int hashCode() {
        int hash = 3;
        hash = 83 * hash + (this.strLabel != null ? this.strLabel.hashCode() : 0);
        hash = 83 * hash + (this.strCommand != null ? this.strCommand.hashCode() : 0);
        return hash;
    }    
}
